package controller

import (
	"Family/common"
	"Family/utils"
	"fmt"

	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

func GinDeleteInfo(ctx *gin.Context) {

	db := common.Connect()
	defer db.Close()

	var data common.Info
	ctx.ShouldBindBodyWith(&data, binding.JSON)
	fmt.Println(data)
	err := utils.Isidexists(db, data.Id)
	if err == false {
		ctx.JSON(200, gin.H{"msg": "用户不存在, 删除失败"})
		return
	}

	common.DeleteInfo(db, data)
	ctx.JSON(200, gin.H{"msg": "删除成功"})
}
